package com.fenghongzhang.lib_dialog

import android.os.Bundle
import android.widget.Button
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.fenghongzhang.lib_dialog.databinding.DialogActivityMainBinding
import com.fenghongzhang.lib_dialog.databinding.DialogActivityRoundBinding
import com.fenghongzhang.lib_dialog.view.CircleProgressView
import com.fenghongzhang.lib_dialog.view.StarProgressView

class RoundActivity : AppCompatActivity() {


    private lateinit var binding: DialogActivityRoundBinding
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding=DialogActivityRoundBinding.inflate(layoutInflater)
        setContentView(binding.root)

        //圆
        val circleProgress = binding.circleProgressView
        val button = binding.controlButton

        //五角星
        val starProgress = binding.starprogressview
        val button1=binding.progress

        //圆
        circleProgress.onLoadingFinished = {
            button.post { button.text = "开始" }
        }
        //五角星
        starProgress.onLoadingFinished = {
            button1.post({ button1.text = "开始" })
        }

        //圆
        button.setOnClickListener {
            circleProgress.toggleLoading()
            button.text = when (circleProgress.getState()) {
                CircleProgressView.LoadingState.PAUSED -> "继续"
                CircleProgressView.LoadingState.LOADING -> "暂停"
                CircleProgressView.LoadingState.IDLE -> "开始"
            }
        }
        //五角星

        button1.setOnClickListener {
            starProgress.toggleLoading()
            button1.text=when(starProgress.getState()){
                StarProgressView.LoadingState.PAUSED->"继续"
                StarProgressView.LoadingState.LOADING->"暂停"
                StarProgressView.LoadingState.IDLE->"开始"
            }
        }
    }
}